<template>
	<view class="custom-content">
		<!-- 自定义页面 -->
		<view v-if="shop.index_content"><u-parse ref="uParse" @imgtap="ignore" :html="shop.index_content"></u-parse></view>
		
		
		<view class="article-list" style="background-color: #fff;padding-top: 30rpx;">
			<view style="font-size: 48rpx;padding: 30rpx;background-color: #fff;">热门内容</view>
			<template v-for="article in articles">
			  <view class="article" @click="openPage('/pages/article/detail',{id:article.id})">
				<u-image mode="widthFix" :src="article.cover"></u-image>
				<view class="u-body-item-title u-line-2 u-flex-1" style="padding-top:30rpx;font-size: 1.2em;line-height: 1.5;font-weight: 600;">{{article.title}}</view>
				<!-- <view style="display: flex;align-items:center;justify-content: space-between;font-size: .9em;">
					<view style="color:rgb(30, 96, 211);">马孚博士爱车会</view>
					<view style="color: rgba(0,0,0,.6);">{{article.read}} 阅读</view>
				</view> -->
			  </view>
			</template>
		</view>
		
		<u-back-top :scroll-top="scrollTop"></u-back-top>
		<wx-share :title='shop.name' :desc="shop.store_introduction" :imgUrl="shop.cover" link="/" ref="wxs"></wx-share>
		<custom-tabbar></custom-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollTop:0,
				shop:{},
				articles:[]
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onLoad() {
			this.getShop();
			this.getArticleList();
		},
		mounted(){
			// this.$refs.uParse.togglePreview(false);
		},
		methods: {
			getShop() {
				this.loading = true;
				this.$u.post('/shopping/shop-setting', {}).then(res => {
					this.shop = res;
					this.loading = false;
				}).catch(e => {
			
				})
			},
			getArticleList() {
				this.$u.post('/article/list', this.paging).then(res => {
				  if (res.page.current_page === 1) {
					this.articles = res.list;
				  } else {
					this.articles = this.articles.concat(res.list)
				  }
				  this.paging.current_page = res.page.current_page;
				  this.paging.total_pages = res.page.total_pages;
				  this.paging.page_size = res.data.page_size;
				}).catch(e => {
				  console.log(e)
				})
			  },
			ignore(event){
				event.ignore();
			},
			openPage(jumpURL, params = {}) {
				this.$u.route({
					type: 'to',
					params: params,
					url: jumpURL,
					animationType: 'slide-in-bottom'
				});
			}
		}
	}
</script>

<style scoped>
.custom-content{
	line-height: 0;
	background: #fff;
}
p{
	line-height: 0;
}
img{
	max-width: 100%;
}
.article{
	padding: 30rpx;
}

</style>
